package org.zsl.ssm.controller;


import com.alibaba.fastjson.JSON;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.zsl.ssm.service.UserService;

import java.io.IOException;

@RestController
@RequestMapping("/user")
public class UserController {

    /**
     *  相当于
     *    service = new UserService();
     * */
    @Autowired
    private UserService service;

    @RequestMapping("/hello")
    public String hello(){
        return "hello";
    }

    @RequestMapping("/all")
    public String getAllUsers() throws IOException {
        return JSON.toJSONString(service.getAllUsers());
    }
}
